package com.队列;

import java.util.Deque;
import java.util.LinkedList;

/**
 * 双队列实现  用的JDK 没有什么难度
 */
public class 用队列实现栈 {
    static class MyStack {
        Deque<Integer> q;
        /** Initialize your data structure here. */
        public MyStack() {
            q = new LinkedList<>();
        }

        /** Push element x onto stack. */
        public void push(int x) {
            q.offer(x);
        }

        /** Removes the element on top of the stack and returns that element. */
        public int pop() {
           return q.pollLast();

        }

        /** Get the top element. */
        public int top() {
            return q.peekLast();
        }

        /** Returns whether the stack is empty. */
        public boolean empty() {
            return q.isEmpty();
        }
    }

    public static void main(String[] args) {
        String s  ="123456";
        String[] str = s.split(":");
       for(String s1:str){
           System.out.println(s1);
       }
    }

}
